/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg2factorialsum;

import java.io.*;
import java.lang.*;
/**
 *
 * @author hhl
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int i = 0;
        String s = "";
        System.out.println("请输入n值：");
        try{
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            s = in.readLine();
        }
        catch(Exception e){}
        i = Integer.parseInt(s);
        System.out.println("shabi");
        int sum = FactorialSum(i);
        System.out.println("从1到" + i + "的阶乘和为：" + sum);
    }

    static int FactorialSum(int n){
    int sum = 0;
    int tempSum = 0;
    for(int i = 1;i <= n; i++){
        tempSum = 1;
        for(int j = 1; j <= i; j++){
            tempSum = tempSum * j;
        }
        sum = sum + tempSum;
    }
    return sum;
    }

}